<template>
  <div class="cartcontrol">
    <transition name="move">
      <div
        class="iconfont  icon-iconremovecircleoutline"
        v-if="food.count"
        @click.stop="updateFoodCount(false)"
      ></div>
    </transition>
    <div class="cart-count" v-if="food.count">{{food.count}}</div>
    <div class="iconfont icon-icon-addcircle-line" @click.stop="updateFoodCount(true)"></div>
    
  </div>
</template>
<script>
export default {
  props: {
    food: Object,
  },
  methods: {
    updateFoodCount(isAdd) {
      this.$store.dispatch("goods/updateFoodCount", { isAdd, food: this.food });
    },
  },
};
</script>

<style lang="scss" scoped>
.cartcontrol {
  display: flex;
  font-size: 0;
  .cart-decrease {
    display: inline-block;
    padding: 6px;
    line-height: 24px;
    font-size: 24px;
    color: rgb(0, 160, 220);
  }
   .icon-iconremovecircleoutline {
    display: inline-block;
    padding: 8px;
    line-height: 24px;
    font-size: 24px;
    color: #ffc135;
    &.move-enter-active, &.move-leave-active {
      transition: all 0.3s;
    }
    &.move-enter, &.move-leave-to {
      opacity: 0;
      transform: translateX(15px) rotate(180deg);
    }
  }
  .cart-count {
    display: inline-block;
    vertical-align: top;
    width: 12px;
    padding-top: 6px;
    line-height: 24px;
    text-align: center;
    margin-top: 4px;
    font-size: 12px;
    color: rgb(147, 153, 159);
  }
  .icon-icon-addcircle-line {
    // display: inline-block;
    padding: 6px;
    line-height: 24px;
    font-size: 24px;
    color: #ffc135;
    margin-top: 5px;
  }
}
</style>
